// pages/canvasP/canvasP.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    rotate: [],
    a:new Date().getTime(),
    b:new Date().getTime()+3
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const timestamp=new Date().getTime()
    for (let i = 0; i < 91; i++) {
      let obj = { rotate: (-270 + (i * 3)) + '' }
      this.data.list.push(obj)
    }
    this.setData({
      list: this.data.list
    })
    this.circleTimeId = null;
    // this.circlePercent();
  },
  circlePercent() {
    let percent = 0;//当前的数据
    let total = 100; //总的数据
    let per = null

    this.circleTimeId = setInterval(() => {
      if (percent > total || percent < 0) {
        console.log('------------1-------------');
        clearInterval(this.circleTimeId);
        return false;
      } else {
        let per1 = -270 * (percent / total); // 当前份额 -- 精确
        let yushu = per1 % 3; // 当前份额对每份角度6取余
        per = Math.abs(per1 - yushu); // 当前份额以6的倍数向下取整
        // per = Math.floor(-180+((percent/total)*100)*6).toFixed(0)
        console.log('per-------------', per);
        // this.data.rotate = "rotate(" + per + "deg)";
        this.data.rotate.push(per) ;
        this.data.list.forEach(ele=>{
          ele.rotate = Math.abs(ele.rotate);
          if(ele.rotate >= per) {
            ele.bg = "";
          }else{
            ele.bg = "red";
          }
        })
        // this.data.rotate = [...new Set(this.data.rotate)]
        console.log(this.data.rotate);
        this.setData({
          // rotate: this.data.rotate
          // rotate: this.data.rotate,
          list: this.data.list,
        })
        percent = percent + 1;
        console.log('percent--------', percent);
      }

    }, 1000);



  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})